package com.sgb.kjwl.viewmodel.self;

import android.content.Context;
import android.os.Build;
import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.im.immodel.IMUtils;
import com.sgb.businessmodule.BusinessConfig;
import com.sgb.businessmodule.entity.BusinessRequestEntity;
import com.sgb.businessmodule.entity.HomeBusinessListEntity;
import com.sgb.contract.view.ui.accountdetail.AccountDetailActivity;
import com.sgb.contract.view.ui.contract.ContractActivity;
import com.sgb.contract.view.ui.list.ContractListActivity;
import com.sgb.contract.view.ui.openaccount.OpenAccountActivity;
import com.sgb.contract.view.ui.openaccount.UserOpenAccountActivity;
import com.sgb.contract.view.ui.openaccount.UserOpenAccountInfoActivity;
import com.sgb.kjwl.BuildConfig;
import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.api.NewAPIManager;
import com.sgb.kjwl.model.entity.SelfOpenAccountDetailEntity;
import com.sgb.kjwl.model.entity.home.RefreshHomeNoticeEVent;
import com.sgb.kjwl.model.entity.self.SecondMore;
import com.sgb.kjwl.utils.DialogFunction;
import com.sgb.kjwl.view.event.ChooseAreaEvent;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.member.entity.PermissionHuiYuanBean;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.MaterialEvent;
import com.swgk.core.base.api.ICallBack;
import com.sgb.kjwl.api.MeManager;
import com.sgb.kjwl.api.NewAPIManager;
import com.sgb.kjwl.api.service.MailListAPI;
import com.sgb.kjwl.api.service.UserAPI;
import com.sgb.kjwl.model.entity.CapitalEntity;
import com.sgb.kjwl.model.entity.LoginEntity;
import com.sgb.kjwl.model.entity.SelfOpenAccountDetailEntity;
import com.sgb.kjwl.model.entity.UserMsgEntity;
import com.sgb.kjwl.model.entity.businessmanagement.CompanyEntity;
import com.sgb.kjwl.model.entity.home.RefreshHomeNoticeEVent;
import com.sgb.kjwl.model.entity.self.ApplyCount;
import com.sgb.kjwl.model.entity.self.ManagementDynamicEntity;
import com.sgb.kjwl.model.entity.self.PermissionChildMuneEntity;
import com.sgb.kjwl.model.entity.self.PermissionMenuEntity;
import com.sgb.kjwl.model.entity.self.TotalUnReadMsgEntity;
import com.sgb.kjwl.model.entity.user.EssentiaIinformationeEntity;
import com.sgb.kjwl.repository.SelfRepertory;
import com.sgb.kjwl.utils.DialogFunction;
import com.sgb.kjwl.utils.MyLog;
import com.sgb.kjwl.utils.UserInfoCacheUtils;
import com.sgb.kjwl.view.ui.activity.WebViewX5HostActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.fragment.SelfFragment5;
import com.sgb.link.entity.PickFilterEntity;
import com.sgb.link.event.MaterialEvent;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.base.model.entity.H5ReEntity;
import com.swgk.core.base.model.entity.ListResponse;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.event.EventConstant;
import com.swgk.core.mmkvutil.CacheMarker;
import com.swgk.core.mmkvutil.DatalUtils;
import com.swgk.core.mmkvutil.MkvUtils;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.util.UserOperating;

import org.greenrobot.eventbus.EventBus;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import androidx.annotation.RequiresApi;
import androidx.lifecycle.MutableLiveData;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SelfFragModel5 extends BaseViewModel {
    public SelfRepertory repertory;
    private SelfFragment5 fragment;
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");

    public SelfFragModel5(SelfFragment5 fragment, SelfRepertory repertory) {
        this.fragment = fragment;
        this.repertory = repertory;
    }

    /**
     * 获取个人信息
     */
    public void getUserInfo() {
        APIManager.getInstance().getUserAPI().getUserInfo().enqueue(new ICallBack<BaseEntity<UserMsgEntity>>() {
            @Override
            public void onSuccess(BaseEntity<UserMsgEntity> data) {
                if (data != null) {
                    //传给fragment的displayRole方法
                    fragment.displayRole(data.getData());
                    //当前身份为企业时获取经营动态信息
                    if (data.getData().getType() == 1||data.getData().getType() == 0) {
                        getManagementDynamicList();//是有企业有经营动态
                        getBusinessListData();
                        getBusinessTypeListData();
                    }
                    fragment.sendMsg();
                    getProcess();
                    //存储个人信息 使用mmkv存储
                    UserInfoCacheUtils.setUserInfo(data.getData());

                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.REAL_ID, data.getData().getCompanyId());
                    //给SharedPreferenceUtil中的USER_NAME赋值 保存用户姓名
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.USER_NAME, data.getData().getUsername());
                    //给SharedPreferenceUtil中的USER_NO赋值 保存用户ID
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.USER_NO, data.getData().getNo());
                    //IM缓存用户信息
                    IMUtils.getInstance().saveIMUserId(data.getData().getCurrentIdentityNo(), data.getData().getRealName());
                    //IM缓存用户头像
                    IMUtils.getInstance().saveIMUserLogo(data.getData().getCurrentIdentityLogo());
                    //IM缓存用户No
                    IMUtils.getInstance().saveUserCurrentCompanyNo(data.getData().getCurrentIdentityNo());
                    //给SharedPreferenceUtil中的DRIVER_AUTH赋值 保存司机认证的状态
                    //(旧数据)司机认证字段 @"NONE"-未认证 @"STANDBY"-认证中  @"FAIL"-认证失败 @"SUCCESS"-认证成功
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.DRIVER_AUTH, data.getData().isDriverAuth() ? "SUCCESS" : "NONE");
                    //给SharedPreferenceUtil中的DRIVER_AUTH赋值 保存企业认证的状态
                    //(旧数据)NONE 未认证  SUCCESS 认证成功
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ENTERPRISE_AUTH, data.getData().isRelevance() ? "SUCCESS" : "NONE");
                    //保存是否关联企业 0未关联  1已关联
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.RELEVANCE, data.getData().isRelevance() ? "1" : "0");
                    //保存个人认证状态[0:未认证,1:已认证]
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.PERSON_AUTH, data.getData().getPersonalAuth() == 1 ? true : false);
                    if (data.getData().getPersonalAuthAuditStatus()==2){
                        //给SharedPreferenceUtil中的REAL_NAME赋值 保存实名认证的状态
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.REAL_NAME, data.getData().getRealName());
                        //保存个人身份证号
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ID_CARD, data.getData().getIdentityCard());
                    }else {
                        //给SharedPreferenceUtil中的REAL_NAME赋值 保存实名认证的状态
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.REAL_NAME, "");
                        //保存个人身份证号
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ID_CARD, "");
                    }
                    //当前用户：0个人，1企业，2团队
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COM_TYPE, data.getData().getType());
                    if (data.getData().getType() != 0){
                        //保存当前企业名称
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NAME, data.getData().getCurrentIdentityName());
                        //保存当前企业logo
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMP_LOGO, data.getData().getCurrentIdentityLogo());
                        //保存当前企业No
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NO, data.getData().getCurrentIdentityNo());
                    }else {
                        //保存当前企业名称
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NAME, "");
                        //保存当前企业logo
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMP_LOGO, "");
                        //保存当前企业No
                        SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NO, "");
                    }
                    //保存是否当前身份加入企业
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.IS_AUTH_OR_JOIN_COMPANY, data.getData().isRelevance());
                    //通知商品首页刷新数据
                    EventBus.getDefault().postSticky(MaterialEvent.make().setMessageTag(EventConstant.EVENT_LOGIN_REF));
                    //通知商品首页刷新数据
                    EventBus.getDefault().postSticky(ChooseAreaEvent.make(EventConstant.EVENT_LOGIN_REF, ""));
                    //通知大首页刷新数据
                    EventBus.getDefault().postSticky(new RefreshHomeNoticeEVent(EventConstant.EVENT_NOTICE_REFRESH_HOME));
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<UserMsgEntity>> call, Throwable t) {
                super.onFailure(call, t);
                fragment.showNoLogin();
            }
        });
        //初始化物流用户操作类，获取用户数据（有缓存取缓存，没缓存重新获取）
        UserOperating.getInstance().refresh();
    }

    /**
     * 公司列表信息
     */
    public void getCompanyList() {
        MyLog.e("获取公司列表", "开始=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
        APIManager.getInstance().getMailListAPI().getUserCompany(MailListAPI.UserCenterUrl.URL_GET_USER_COMPANY).enqueue(new ICallBack<BaseEntity<List<CompanyEntity>>>(true, false) {
            @Override
            public void onSuccess(BaseEntity<List<CompanyEntity>> data) {
                MyLog.e("获取公司列表", "结束=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
                if (data != null && data.getData() != null) {
                    fragment.showCompanyList(data.getData());
                } else {
                    fragment.showCompanyList(new ArrayList<>());
                }
            }
        });
    }

    /**
     * 切换企业
     * 描述:切换完企业后必须调用后台接口保持前后端当前身份一致
     *
     * @param companyEntity
     */
    public void toggleCurrentCompany(CompanyEntity companyEntity) {
        MyLog.e("切换企业", "开始=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
        APIManager.getInstance().getMailListAPI().settingMainCompany(companyEntity.getCompNo(), companyEntity.getType()).enqueue(new ICallBack<BaseEntity<LoginEntity>>(true, true) {
            @Override
            public void onSuccess(BaseEntity<LoginEntity> data) {
                if (data == null || data.getData() == null) {
                    return;
                }
                getUserInfo();

               /* LoginEntity entity = data.getData();
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourcePCToken, entity.getResourcePCToken());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourceAPPToken, entity.getResourceAPPToken());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PC_TOKEN, entity.getResourcePCToken());
                //给SharedPreferenceUtil中的COMPANY_NO赋值 保存公司ID
                Log.e("公司no", companyEntity.getCompNo());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NO, companyEntity.getCompNo());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ENTERPRISE_NO, companyEntity.getCompNo());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NAME, companyEntity.getCompName());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMP_LOGO, companyEntity.getCompLogo());
                //查询个人中心商品列表
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.REAL_ID, companyEntity.getCompanyId());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COM_TYPE, companyEntity.getType());

                //设置主企业成功 获取动态经营和商机服务 切换token
                if (SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 1) == 1) {
                    getManagementDynamicList();//是有企业有经营动态
                    getBusinessListData();
                    getBusinessTypeListData();
                }
                repertory.saveToken(entity.getToken());
                fragment.sendMsg();
                getProcess();
                //通知商品首页刷新数据
                EventBus.getDefault().postSticky(MaterialEvent.make().setMessageTag(EventConstant.EVENT_LOGIN_REF));
                //通知大首页刷新数据
                EventBus.getDefault().postSticky(new RefreshHomeNoticeEVent(EventConstant.EVENT_NOTICE_REFRESH_HOME));*/
            }
        });
    }

    /**
     * 设置主企业
     *
     * @param companyEntity
     */
    public void settingMainCompany(CompanyEntity companyEntity) {
      /*  MyLog.e("设置主企业", "开始=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
        APIManager.getInstance().getMailListAPI().settingMainCompany(companyEntity.getCompNo(), companyEntity.getType()).enqueue(new ICallBack<BaseEntity<LoginEntity>>(true, true) {
            @Override
            public void onSuccess(BaseEntity<LoginEntity> data) {
                MyLog.e("设置主企业", "结束=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
                if (data == null || data.getData() == null) {
                    return;
                }
                LoginEntity entity = data.getData();
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourcePCToken, entity.getResourcePCToken());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourceAPPToken, entity.getResourceAPPToken());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PC_TOKEN, entity.getResourcePCToken());
                //给SharedPreferenceUtil中的COMPANY_NO赋值 保存公司ID
                Log.e("公司no", companyEntity.getCompNo());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NO, companyEntity.getCompNo());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ENTERPRISE_NO, companyEntity.getCompNo());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMPANY_NAME, companyEntity.getCompName());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COMP_LOGO, companyEntity.getCompLogo());
                //查询个人中心商品列表
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.REAL_ID, companyEntity.getCompanyId());
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.COM_TYPE, companyEntity.getType());

                //设置主企业成功 获取动态经营和商机服务 切换token
                if (SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 1) == 1) {
                    getManagementDynamicList();//是有企业有经营动态
                    getBusinessListData();
                    getBusinessTypeListData();
                }
                repertory.saveToken(entity.getToken());
                fragment.sendMsg();
                getProcess();
                //通知商品首页刷新数据
                EventBus.getDefault().postSticky(MaterialEvent.make().setMessageTag(EventConstant.EVENT_LOGIN_REF));
                //通知大首页刷新数据
                EventBus.getDefault().postSticky(new RefreshHomeNoticeEVent(EventConstant.EVENT_NOTICE_REFRESH_HOME));

            }
        });*/
    }


    /**
     * 获取用户的基本信息
     */
    public void getEssentialInformation(String no, int type) {
        APIManager.getInstance().getUserAPI().getEssential_information(no, type + "").enqueue(new ICallBack<BaseEntity<EssentiaIinformationeEntity>>(true, false) {
            @Override
            public void onSuccess(BaseEntity<EssentiaIinformationeEntity> data) {
                if (data == null || data.getData() == null) {
                    return;
                }
                String CacheMateialistlHash = DatalUtils.getHashData(MkvUtils.get().CommomData, CacheMarker.CacheUserInfo);
                Gson gson = new Gson();
                //获取从网络请求下来的数据的哈希值
                String data1 = gson.toJson(data.getData());
                String mHashNet = DatalUtils.strToHashKey(data1);
                //临时关闭团队类型展示
                //fragment.showHeadPortrait(response.body().getData());
                if (!CacheMateialistlHash.equals(mHashNet)) {
                    //存储用户的基本信息
                    UserInfoCacheUtils.setUserInfoData(data.getData());
                }
                EventBus.getDefault().postSticky(EventConstant.EVENT_REFRESH_MAIN_GOODS);
            }

            @Override
            public void onFailure(Call<BaseEntity<EssentiaIinformationeEntity>> call, Throwable t) {
                super.onFailure(call, t);
                DialogHelper.dismissProgressDialog();
            }
        });
    }
    //获取配置的常用菜单
    public void GetToplist( int clientType, String siteNo, int siteType ){
        map.put("clientType",clientType);
        map.put("siteNo",siteNo);
        map.put("siteType",siteType);
        APIManager.getInstance().getUserAPI().commonApplicationlist(map).enqueue(new Callback<BaseEntity<SecondMore.DataDTO>>() {
            @Override
            public void onResponse(Call<BaseEntity<SecondMore.DataDTO>> call, Response<BaseEntity<SecondMore.DataDTO>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null) return;
                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
                    fragment.showchagnyongMenu(response.body().getData());
                } else {
                    MToast.showToast(fragment.getActivity(), response.body().getMsg());
                }

            }

            @Override
            public void onFailure(Call<BaseEntity<SecondMore.DataDTO>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
//                MToast.showToast(fragment.getActivity(), t.getMessage());
            }
        });
    }
    /**
     * 获取我的页面菜单数据
     */
    public void getPermissionMenu(String no, int type) {
        MyLog.e("获取一级菜单", "开始=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
        APIManager.getInstance().getUserAPI().getPermissionMenu(no, type).enqueue(new ICallBack<BaseEntity<List<PermissionMenuEntity>>>(true, true) {
            @Override
            public void onSuccess(BaseEntity<List<PermissionMenuEntity>> data) {
                if (data != null && data.getData() != null) {
                    Gson gson = new Gson();
                    String s = gson.toJson(data.getData(), new TypeToken<List<PermissionMenuEntity>>() {
                    }.getType());
                    List<PermissionMenuEntity> datas = data.getData();
                    List<PermissionMenuEntity> list = new ArrayList<>();
                    if (datas != null && datas.size() != 0) {
                        list.addAll(datas);
                    }
                    //list.add(0, addEntity());
                    fragment.showPermissionMenu(getReallyMenu(list, type));
                    DatalUtils.getInstance().putData(MkvUtils.CacheUserCenterMenu, CacheMarker.USER_CENTER_MENU + no, list);
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.IS_DATA, s);
                    getPermissionChildMenu();
                    //getApplyCount();
                } else {
                    fragment.dismissRefresh();
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PermissionMenuEntity>>> call, Throwable t) {
                //去登录
                if (fragment != null && fragment.getActivity() != null && !fragment.getActivity().isFinishing()) {
                    VerificationCodeLoginActivity.start(fragment.getActivity(), false);
                }

                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_TOKEN, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PC_TOKEN, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PHONE, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourcePCToken, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourceAPPToken, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ENTERPRISE_AUTH, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.PERSON_AUTH, false);
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.DRIVER_AUTH, "");
                repertory.saveToken(null);
//                NimUIKit.setAccount("");
//                AVChatKit.setAccount("");
                fragment.dismissRefresh();
                fragment.getData();
            }
        });

    }
    public void getPermissionHuiYuan() {
        //返回页面数据
        APIManager.getInstance().getUserAPI().getPermissionHuiYuan().enqueue(new Callback<BaseEntity<List<PermissionHuiYuanBean>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PermissionHuiYuanBean>>> call, Response<BaseEntity<List<PermissionHuiYuanBean>>> response) {
                if (response != null && response.body() != null && response.body().getData() != null) {
                    String s = new Gson().toJson(response.body().getData(), new TypeToken<List<PermissionMenuEntity>>() {}.getType());
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.PERMISSION_HUI_YUAN, s);
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PermissionHuiYuanBean>>> call, Throwable t) {
            }
        });
    }


    String[] personStr = new String[]{"0_wodejianli", "0_wodeqiuzhi", "0_wodetoudi", "0_zulinfabu", "0_shipinfabu",
            "0_renzhengzhongxin", "0_qiyezizhi", "0_yejizhengming", "0_qiyedongtai", "0_hangyerongyu", "0_qiyexiangce",
            "0_zhishichanquan"};
    String[] companyStr = new String[]{"0_shangpinfabu", "0_zhaobiaofabu", "0_fabuhuoyuan", "0_jicaifabu",
            "0_gongduifabu", "0_gongrenfabuhome", "0_laowufabu", "0_huoyunfabu", "0_zulinfabu", "0_wodezhuanrang",
            "0_wodefuwu", "0_wodexuqiu", "0_qiyezizhi", "0_yejizhengming", "0_qiyedongtai",
            "0_hangyerongyu", "0_qiyexiangce", "0_zhishichanquan", "0_yaoqingjingjia", "0_yaoqingbaoming", "0_yaoqingbaojia"
            , "0_yaoqingjiameng", "0_shenqinghuiyuan", "0_yaoqinghuiyuan", "0_zuzhijiagou", "0_yuangongjiaru", "0_yaoqingchengyuan",
            "0_caiwuzhongxin", "0_tongxunlu", "0_kaipiaoxinxi", "0_dizhiguanli", "0_renzhengzhongxin", "0_zhanghuanquan", "0_quanxianguanli"
            , "0_pinpaifenji", "0_shangpincuxiao", "0_wodexinxi", "0_erweimamingpian", "0_guanfangkefu", "0_fenxiangapp", "0_yijianfenkui", "0_shezhi"};
    String[] groupStr = new String[]{"0_wodezhuanrang", "0_wodefuwu", "0_wodexuqiu", "0_renzhengzhongxin",
            "0_qiyezizhi", "0_yejizhengming", "0_qiyedongtai", "0_hangyerongyu", "0_qiyexiangce", "0_zhishichanquan"};
    String[] organization = new String[]{"0_fabuzhaoshang", "0_renzhengzhongxin"};

    //首页区分个人 团队 组织
    private List<PermissionMenuEntity.ListEntity> mHomeThirdMenus = new ArrayList<>();

    private List<PermissionMenuEntity> getReallyMenu(List<PermissionMenuEntity> list, int type) {
        mHomeThirdMenus.clear();
        if (list != null && !list.isEmpty()) {
            PermissionMenuEntity entity = list.get(0);
            if ("首页".equals(entity.getTitle()) && entity.getList() != null && entity.getList().size() == 1) {
                PermissionMenuEntity.ListEntity secondEntity = entity.getList().get(0);
                if (secondEntity != null && secondEntity.getList() != null) {
                    for (PermissionMenuEntity.ListEntity thirdEntity : secondEntity.getList()) {
                        if (thirdEntity != null) {
                            if (type == 0) { //企业
                                if (Arrays.asList(personStr).contains(thirdEntity.getName())) {
                                    mHomeThirdMenus.add(thirdEntity);
                                }
                            } else if (type == 1) {
                                if (Arrays.asList(companyStr).contains(thirdEntity.getName())) {
                                    mHomeThirdMenus.add(thirdEntity);
                                }
                            } else if (type == 2) {
                                if (Arrays.asList(groupStr).contains(thirdEntity.getName())) {
                                    mHomeThirdMenus.add(thirdEntity);
                                }
                            } else if (type == 3) {
                                if (Arrays.asList(organization).contains(thirdEntity.getName())) {
                                    mHomeThirdMenus.add(thirdEntity);
                                }
                            }
                            secondEntity.setList(mHomeThirdMenus);
                        }
                    }
                }
            }
        }

        return list;
    }

    //首页
    private void addConstMenu(int type) {
        mHomeThirdMenus.clear();
    }

    public void getApplyCount() {
        int type = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
        //类型 0个人 1企业 2团队
        if (type != 1) {//不为企业的时候的不请求
            return;
        }
        //DialogHelper.showProgressDialog(fragment.getContext(), null, "请求中...", 0, false, null).setCanceledOnTouchOutside(false);
//        APIManager.getInstance().changeAPIManager(BuildConfig.BASE_URL_DESIGN);
        Map<String, Object> map = new HashMap<>();
        map.put("companyId", SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NO, ""));
        map.put("userId", SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""));
        String url = BuildConfig.BASE_URL_DESIGN + "v1/pc/process/applyCount";
        APIManager.getInstance().getUserAPI().getApplyCount(url, map).enqueue(new ICallBack<BaseEntity<ApplyCount>>(false, false) {
            @Override
            public void onSuccess(BaseEntity<ApplyCount> data) {
                if (data != null && data.getData() != null) {
                    fragment.setApplyCount(data.getData());
                }
            }
        });
    }

    PermissionMenuEntity entity, approvalEntity;

    //常用功能
    private PermissionMenuEntity addEntity() {
        if (entity == null)
            entity = new PermissionMenuEntity();
        entity.setTitle("常用功能");

        List<PermissionMenuEntity.ListEntity> list = new ArrayList<>();
        PermissionMenuEntity.ListEntity listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("jibenxinxi");
        listEntity.setTitle("基本信息");
        listEntity.setName("common_jibenxinxi");
        list.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("jiaruqiye");
        listEntity.setTitle("加入企业");
        listEntity.setName("common_jiaruqiye");
        list.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("renzhengzhongxin");
        listEntity.setTitle("认证中心");
        listEntity.setName("common_renzhengzhongxin");
        list.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("wodexunjia");
        listEntity.setTitle("我的询价");
        listEntity.setName("common_wodexunjia");
        list.add(listEntity);

//        listEntity = new PermissionMenuEntity.ListEntity();
//        listEntity.setIcon("hanxunhuifu");
//        listEntity.setTitle("函询回复");
//        listEntity.setName("common_hanxunhuifu");
//        list.add(listEntity);

        //根据需求注释
        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("wodepingbiao");
        listEntity.setTitle("我的评标");
        listEntity.setName("common_wodepingbiao");
        list.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("zigeshencha");
        listEntity.setTitle("资格审查");
        listEntity.setName("common_zigeshencha");
        list.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("wodejubao");
        listEntity.setTitle("举报监督");
        listEntity.setName("common_jubaojiandu");
        list.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("zhinengguanzhu");
        listEntity.setTitle("智能关注");
        listEntity.setName("common_zhinengguanzhu");
        list.add(listEntity);


        entity.setList(list);

        return entity;
    }


    /**
     * 缓存菜单字列表的数据
     */

    public void getPermissionChildMenu() {
        MyLog.e("获取二级权限", "开始=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
        APIManager.getInstance().getUserAPI().getPermissionChildMune().enqueue(new ICallBack<BaseEntity<PermissionChildMuneEntity>>(false, false) {
            @Override
            public void onSuccess(BaseEntity<PermissionChildMuneEntity> data) {
                if (data != null && data.getData() != null) {
                    Gson gson = new Gson();
                    String s = gson.toJson(data.getData(), new TypeToken<PermissionChildMuneEntity>() {
                    }.getType());
                    SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.CHILD_MENU, s);
                }
                MyLog.e("获取二级权限", "结束=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
            }
        });

    }

    /**
     * 通过标识来获取跳转连接
     *
     * @param map
     */
    public void getStringUrl(Map<String, String> map) {
        String name = map.get("name");
        String type = map.get("type");
        String typeUrl = map.get("typeUrl");
        String param = type;
        final String urlId = typeUrl;
        DialogHelper.showProgressDialog(fragment.getContext(), null, "加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        APIManager.getInstance().getPickAPI().getUrlSetting(param).enqueue(new ICallBack<BaseEntity<H5ReEntity>>() {
            @Override
            public void onSuccess(BaseEntity<H5ReEntity> data) {
                //DialogHelper.dismissProgressDialog();
                if (data == null || data.getState() == null) {
                    return;
                }
                if (data.getState().equals(APIManager.RESPONSE_OK)) {
                    String url = data.getData().getUrl() + urlId;
                    WebViewX5HostActivity.start(fragment.getActivity(), url);
                }
            }
        });
    }


    /**
     * 获取开户信息
     */
    public void getProcess() {
        MeManager.getInstance().getMaterialAPI().getProcess().enqueue(new ICallBack<BaseEntity<CapitalEntity>>(true, true) {
            @Override
            public void onSuccess(BaseEntity<CapitalEntity> data) {
                if (data == null || data.getData() == null) {
                    return;
                }
                fragment.getProcess(data.getData());
            }
        });
    }

    public void getTotalUnReadMsg(boolean isRefresh) {
        APIManager.getInstance().getUserAPI().getTotalUnReadMsg().enqueue(new ICallBack<BaseEntity<TotalUnReadMsgEntity>>() {
            @Override
            public void onSuccess(BaseEntity<TotalUnReadMsgEntity> data) {
                if (data != null && data.getData() != null) {
                    fragment.getTotalUnReadMsg(data.getData(), isRefresh);
                }
            }
        });
    }


    //订单总未读
    private int mTotalOrderNum = 0;

    //商品未读
    private int mTotalShopNum = 0;

    //租赁未读
    private int mTotalLeaseNum = 0;


    //获取订单未读数量
    public int getTotalOrderNum(TotalUnReadMsgEntity data, List<PickFilterEntity<ArrayList<PickFilterEntity<Object>>>> mMenus) {
        mTotalOrderNum = 0;
        mTotalShopNum = 0;
        mTotalLeaseNum = 0;

        if (mMenus.isEmpty()) {
            getOrderNum(mTotalShopNum, mTotalLeaseNum, 0, mMenus);
            return mTotalOrderNum;
        }
        for (PickFilterEntity<ArrayList<PickFilterEntity<Object>>> firstEntity : mMenus) {
            if (firstEntity != null && firstEntity.getChildren() != null && !firstEntity.getChildren().isEmpty()) {
                for (PickFilterEntity<Object> secondEntity : firstEntity.getChildren()) {
                    if ("5".equals(secondEntity.getNo())) {//采购订单数量
                        mTotalOrderNum = mTotalOrderNum + data.getCaiGouOrderCount();
                        mTotalShopNum = mTotalShopNum + data.getCaiGouOrderCount();
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + (data.getCaiGouOrderCount() > 99 ? 99 + "+" : data.getCaiGouOrderCount()) + ")");
                    } else if ("6".equals(secondEntity.getNo())) {//销售订单数量
                        mTotalOrderNum = mTotalOrderNum + data.getSaleOrderCount();
                        mTotalShopNum = mTotalShopNum + data.getSaleOrderCount();
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }

                        secondEntity.setName(secondEntity.getName() + "(" + (data.getSaleOrderCount() > 99 ? 99 + "+" : data.getSaleOrderCount()) + ")");
                    } else if ("8".equals(secondEntity.getNo())) {//求租订单数量
                        mTotalOrderNum = mTotalOrderNum + data.getQiuZuOrderCount();
                        mTotalLeaseNum = mTotalLeaseNum + data.getQiuZuOrderCount();
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + (data.getQiuZuOrderCount() > 99 ? 99 + "+" : data.getQiuZuOrderCount()) + ")");
                    } else if ("7".equals(secondEntity.getNo())) {//出租订单数量
                        mTotalOrderNum = mTotalOrderNum + data.getChuZuOrderCount();
                        mTotalLeaseNum = mTotalLeaseNum + data.getChuZuOrderCount();
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + (data.getChuZuOrderCount() > 99 ? 99 + "+" : data.getChuZuOrderCount()) + ")");
                    } else if ("11".equals(secondEntity.getNo())) {//货运订单数量
                        mTotalOrderNum = mTotalOrderNum + data.getHuoYunOrderCount();
                    }
                }
            }
        }
        getOrderNum(mTotalShopNum, mTotalLeaseNum, data.getHuoYunOrderCount(), mMenus);
        return mTotalOrderNum;
    }

    private void getOrderNum(int orderShopNum, int orderLeaseShop, int orderTranNum, List<PickFilterEntity<ArrayList<PickFilterEntity<Object>>>> mMenus) {
        for (PickFilterEntity<ArrayList<PickFilterEntity<Object>>> firstEntity : mMenus) {
            if ("1".equals(firstEntity.getNo())) { //商品订单
                if (firstEntity.getName().contains("(")) {
                    firstEntity.setName(firstEntity.getName().substring(0, firstEntity.getName().indexOf("(")));
                }
                firstEntity.setName(firstEntity.getName() + "(" + (mTotalShopNum > 99 ? 99 + "+" : mTotalShopNum) + ")");
            } else if ("2".equals(firstEntity.getNo())) {//租赁订单
                if (firstEntity.getName().contains("(")) {
                    firstEntity.setName(firstEntity.getName().substring(0, firstEntity.getName().indexOf("(")));
                }
                firstEntity.setName(firstEntity.getName() + "(" + (mTotalLeaseNum > 99 ? 99 + "+" : mTotalLeaseNum) + ")");
            } else if ("3".equals(firstEntity.getNo()) && !firstEntity.getName().contains("(")) {//物流订单
                if (firstEntity.getName().contains("(")) {
                    firstEntity.setName(firstEntity.getName().substring(0, firstEntity.getName().indexOf("(")));
                }
                firstEntity.setName(firstEntity.getName() + "(" + (orderTranNum > 99 ? 99 + "+" : orderTranNum) + ")");
            }
        }
        fragment.getOrderMenus(mMenus);
    }

    public void getJiCaiNum(int mJiCaiJiaMengNum, int mJiCaiBaoJiaNum, List<PickFilterEntity<ArrayList<PickFilterEntity<Object>>>> mCentralizedMiningMenus) {
        if (mCentralizedMiningMenus.isEmpty()) return;
        for (PickFilterEntity<ArrayList<PickFilterEntity<Object>>> firstEntity : mCentralizedMiningMenus) {
            if ("14".equals(firstEntity.getNo())) { //收到的集采
                if (firstEntity.getName().contains("(")) {
                    firstEntity.setName(firstEntity.getName().substring(0, firstEntity.getName().indexOf("(")));
                }
                firstEntity.setName(firstEntity.getName() + "(" + ((mJiCaiJiaMengNum + mJiCaiBaoJiaNum) > 99 ? 99 + "+" : (mJiCaiJiaMengNum + mJiCaiBaoJiaNum)) + ")");
            } else if ("15".equals(firstEntity.getNo())) {//发起的集采
                firstEntity.setName(firstEntity.getName() + "(" + 0 + ")");
                if (firstEntity.getName().contains("(")) {
                    firstEntity.setName(firstEntity.getName().substring(0, firstEntity.getName().indexOf("(")));
                }
                firstEntity.setName(firstEntity.getName() + "(" + 0 + ")");
            }
            if (firstEntity != null && firstEntity.getChildren() != null && !firstEntity.getChildren().isEmpty()) {
                for (PickFilterEntity<Object> secondEntity : firstEntity.getChildren()) {
                    if ("12".equals(secondEntity.getNo())) { //加盟单位
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + (mJiCaiJiaMengNum > 99 ? 99 + "+" : mJiCaiJiaMengNum) + ")");
                    } else if ("13".equals(secondEntity.getNo())) {//报价单位
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + mJiCaiBaoJiaNum + ")");
                    } else if ("16".equals(secondEntity.getNo())) {//需方发起
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + 0 + ")");
                    } else if ("17".equals(secondEntity.getNo())) {//企业专项
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + 0 + ")");
                    } else if ("18".equals(secondEntity.getNo())) {//供方发起
                        if (secondEntity.getName().contains("(")) {
                            secondEntity.setName(secondEntity.getName().substring(0, secondEntity.getName().indexOf("(")));
                        }
                        secondEntity.setName(secondEntity.getName() + "(" + 0 + ")");
                    }
                }
            }
        }
        fragment.getCentralizedMiningMenus(mCentralizedMiningMenus);
    }

    //审批代办
    List<PermissionMenuEntity.ListEntity> mApprovalAgentList = new ArrayList<>();

    /**
     * @param type 0--个人 1--企业 2--团队
     * @return
     */
    PermissionMenuEntity.ListEntity listEntity;

    public void getApprovalAgent(int type) {
        mApprovalAgentList.clear();

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("daiban");
            listEntity.setTitle("审批");
            listEntity.setName("1_daiban");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 0 || type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("dingdan");
            listEntity.setTitle("订单");
            listEntity.setName("7_dingdan");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("hetong");
            listEntity.setTitle("合同");
            listEntity.setName("16_hetong");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("fukuan");
            listEntity.setTitle("付款");
            listEntity.setName("8_fukuan");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }


//        if (type == 1) {
//            listEntity = new PermissionMenuEntity.ListEntity();
//            listEntity.setIcon("ucshenqing");
//            listEntity.setTitle("申请");
//            listEntity.setName("11_ucshenqing");
//            listEntity.setCount(0);
//            mApprovalAgentList.add(listEntity);
//        }

//        if (type == 1) {
//            listEntity = new PermissionMenuEntity.ListEntity();
//            listEntity.setIcon("yuangongshenhe_agent");
//            listEntity.setTitle("员工审核");
//            listEntity.setName("20_yuangongshenhe");
//            listEntity.setCount(0);
//            mApprovalAgentList.add(listEntity);
//        }
//        if (type == 1) {
//            listEntity = new PermissionMenuEntity.ListEntity();
//            listEntity.setIcon("huiyuanshenhe_agent");
//            listEntity.setTitle("会员审核");
//            listEntity.setName("21_huiyuanshenhe");
//            listEntity.setCount(0);
//            mApprovalAgentList.add(listEntity);
//        }

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setTitle("函询");
        listEntity.setName("5_hanxun");
        listEntity.setCount(0);
        mApprovalAgentList.add(listEntity);


        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("jiandu");
        listEntity.setTitle("监督");
        listEntity.setName("9_jiandu");
        listEntity.setCount(0);
        mApprovalAgentList.add(listEntity);

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("shangji");
            listEntity.setTitle("商机");
            listEntity.setName("6_shangji");
            listEntity.setCount(0);
            //mApprovalAgentList.add(listEntity);
        }

//        if (type == 1) {
//            listEntity = new PermissionMenuEntity.ListEntity();
//            listEntity.setIcon("gouwuche_agent");
//            listEntity.setTitle("购物车");
//            listEntity.setName("22_gouwuche");
//            listEntity.setCount(0);
//            mApprovalAgentList.add(listEntity);
//        }


        if (type != 3) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("xunjia");
            listEntity.setTitle("询价");
            listEntity.setName("10_xunjia");
            listEntity.setCount(0);
            if (type == 1) {
                mApprovalAgentList.add(4, listEntity);
            } else {
                mApprovalAgentList.add(listEntity);
            }

        }

        if (type == 0) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("zhinengguanzhu");
            listEntity.setTitle("关注");
            listEntity.setName("14_guanzhu");
            listEntity.setCount(0);
            //mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("ucjingjia");
            listEntity.setTitle("竞价");
            listEntity.setName("12_ucjingjia");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("zhaobiao");
            listEntity.setTitle("招标");
            listEntity.setName("17_zhaobiao");
            listEntity.setCount(0);
            //mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("ucjicai");
            listEntity.setTitle("集采");
            listEntity.setName("13_ucjicai");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1||type==0) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("yaoqing_agent");
            listEntity.setTitle("邀请");
            listEntity.setName("23_yaoqing");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("baoming");
            listEntity.setTitle("报名");
            listEntity.setName("24_baoming");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("baojia");
            listEntity.setTitle("报价");
            listEntity.setName("24_baojia");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }
        if (type == 1 || type == 0) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("xinhuiyuan");
            listEntity.setTitle("新会员");
            listEntity.setName("24_xinhuiyuan");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }
        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("xinchengyuan");
            listEntity.setTitle("新成员");
            listEntity.setName("24_xinchengyuan");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }

        if (type == 1) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("xinyuangong");
            listEntity.setTitle("新员工");
            listEntity.setName("24_xinyuangong");
            listEntity.setCount(0);
            mApprovalAgentList.add(listEntity);
        }
        fragment.renderHeadView(mApprovalAgentList);
    }

    //审批代办
    List<PermissionMenuEntity.ListEntity> mNoAuthList = new ArrayList<>();
    public void getNoAuth(boolean isAuth) {
        mNoAuthList.clear();

//        if (!isAuth){
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("gerenrenzheng");
            listEntity.setTitle("个人认证");
            listEntity.setName("0_gerenrenzheng");
            mNoAuthList.add(listEntity);
//        }


        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("sijirenzheng");
        listEntity.setTitle("司机认证");
        listEntity.setName("0_sijirenzheng");
        mNoAuthList.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("qiyerenzheng");
        listEntity.setTitle("企业认证");
        listEntity.setName("0_qiyerenzheng");
        mNoAuthList.add(listEntity);

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("tuanduirenzheng_no_auth");
        listEntity.setTitle("团队认证");
        listEntity.setName("0_tuanduirenzheng");
        mNoAuthList.add(listEntity);

        if (isAuth) {
            listEntity = new PermissionMenuEntity.ListEntity();
            listEntity.setIcon("zuzhirenzheng");
            listEntity.setTitle("政府单位");
            listEntity.setName("0_zuzhirenzheng");
            mNoAuthList.add(listEntity);
        }

        listEntity = new PermissionMenuEntity.ListEntity();
        listEntity.setIcon("jiaruqiye_no_auth");
        listEntity.setTitle("员工加入");
        listEntity.setName("0_jiaruqiye");
        mNoAuthList.add(listEntity);



        fragment.renderNoAuthView(mNoAuthList);
    }


//    /**
//     * 获取企业
//     */
//    public void getBusinessInfoByCompany() {
//        MeManager.getInstance().getMaterialAPI().getBusinessInfoByCompany().enqueue(new Callback<BaseEntity<BusinessInfoByCompanyEntity>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<BusinessInfoByCompanyEntity>> call, Response<BaseEntity<BusinessInfoByCompanyEntity>> response) {
//                DialogHelper.dismissProgressDialog();
//                if (response.body() == null) return;
//                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
//                    fragment.getBusinessInfoByCompany(response.body().getData());
//                } else {
//                    DialogHelper.dismissProgressDialog();
//                    MToast.showToast(fragment.getActivity(), response.body().getMsg());
//                }
//            }
//
//            @Override
//            public void onFailure(Call<BaseEntity<BusinessInfoByCompanyEntity>> call, Throwable t) {
//                DialogHelper.dismissProgressDialog();
//                MToast.showToast(fragment.getActivity(), t.getMessage());
//            }
//        });
//    }
//
//    /**
//     * 获取个人和团队信息
//     */
//    public void getBusinessInfoByUser() {
//        MeManager.getInstance().getMaterialAPI().getBusinessInfoByUser().enqueue(new Callback<BaseEntity<BusinessInfoByCompanyEntity>>() {
//            @Override
//            public void onResponse(Call<BaseEntity<BusinessInfoByCompanyEntity>> call, Response<BaseEntity<BusinessInfoByCompanyEntity>> response) {
//                DialogHelper.dismissProgressDialog();
//                if (response.body() == null) return;
//                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
//                    fragment.getBusinessInfoByCompany(response.body().getData());
//                } else {
//                    MToast.showToast(fragment.getActivity(), response.body().getMsg());
//                }
//            }
//
//            @Override
//            public void onFailure(Call<BaseEntity<BusinessInfoByCompanyEntity>> call, Throwable t) {
//                DialogHelper.dismissProgressDialog();
//                MToast.showToast(fragment.getActivity(), t.getMessage());
//            }
//        });
//    }


    //经营动态
    public MutableLiveData<List<ManagementDynamicEntity>> mManagementDynamicList = new MutableLiveData();
    Map<String, Object> map = new HashMap<>();

    public void getManagementDynamicList() {
        map.put("page", 1);
        map.put("limit", 5);
        map.put("type", "");
        APIManager.getInstance().getUserAPI().getManagementDynamicList(UserAPI.UserCenterUrl.URL_MANAGEMENT_DYNAMIC, map)
                .enqueue(new ICallBack<BaseEntity<ListResponse<List<ManagementDynamicEntity>>>>() {
                    @Override
                    public void onSuccess(BaseEntity<ListResponse<List<ManagementDynamicEntity>>> data) {
                        if (data != null && data.getData() != null && data.getData().getList() != null) {
                            mManagementDynamicList.postValue(data.getData().getList());
                        }
                    }

                    @Override
                    public void onFailure(Call<BaseEntity<ListResponse<List<ManagementDynamicEntity>>>> call, Throwable t) {
                        //super.onFailure(call, t);
                    }
                });
    }

    //大厅列表数据
    public MutableLiveData<List<HomeBusinessListEntity>> businessList = new MutableLiveData();

    /*
     * 获取商机大厅列表数据
     * */
    public void getBusinessListData() {
        BusinessRequestEntity entity = new BusinessRequestEntity();
        entity.setPage(1);
        entity.setLimit(5);
        entity.setMatchStatus(true);
        BusinessRequestEntity.SortFieldBean bean = new BusinessRequestEntity.SortFieldBean();
        bean.setPublishTime(false);
        entity.setSortField(bean);
        BusinessConfig.getInstance().getApi().getHomeBusinessData(entity).enqueue(new ICallBack<BaseEntity<ListResponse<List<HomeBusinessListEntity>>>>(true, true) {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<HomeBusinessListEntity>>> data) {
                if (data.getData().getList() != null) {
                    businessList.postValue(data.getData().getList());
                }
            }
        });
    }

    /*
     * 获取自主订阅列表数据
     * */
    public void getSubscribeBusinessListData() {
        BusinessRequestEntity entity = new BusinessRequestEntity();
        entity.setPage(1);
        entity.setLimit(5);
        //entity.setMatchStatus(true);
        entity.setCityNo(new ArrayList<>());
        entity.setOnlySubscriptionInformation(true);
        BusinessRequestEntity.SortFieldBean bean = new BusinessRequestEntity.SortFieldBean();
        bean.setPublishTime(false);
        entity.setSortField(bean);
        BusinessConfig.getInstance().getApi().getHomeBusinessData(entity).enqueue(new ICallBack<BaseEntity<ListResponse<List<HomeBusinessListEntity>>>>(true, true) {
            @Override
            public void onSuccess(BaseEntity<ListResponse<List<HomeBusinessListEntity>>> data) {
                if (data.getData().getList() != null) {
                    businessList.postValue(data.getData().getList());
                }
            }
        });
    }

    /**
     * 获取商机类型
     */
    List<PickFilterEntity> businessType = new ArrayList<>();
    public MutableLiveData<List<PickFilterEntity>> businessTypeList = new MutableLiveData();
    PickFilterEntity pickFilterEntity;

    public void getBusinessTypeListData() {
        businessType.clear();
        pickFilterEntity = new PickFilterEntity("0", "商机大厅");
        pickFilterEntity.setChoose(true);
        businessType.add(pickFilterEntity);
        pickFilterEntity = new PickFilterEntity("1", "推荐商机");
        businessType.add(pickFilterEntity);
        pickFilterEntity = new PickFilterEntity("2", "自主订阅");
        businessType.add(pickFilterEntity);
        businessTypeList.postValue(businessType);
    }

    /***
     *  是否开户合同权限判断
     *  isUser: 判断是否是个人
     */

    public void getCompanyDetail(Context context, int tag,boolean isUser) {
        DialogHelper.showProgressDialog(context, null, "数据加载中", 0, true, null).setCanceledOnTouchOutside(false);
        NewAPIManager.getInstance().getCommonAPI().getCompanyDetail().enqueue(new Callback<BaseEntity<SelfOpenAccountDetailEntity>>() {
            @Override
            public void onResponse(Call<BaseEntity<SelfOpenAccountDetailEntity>> call, Response<BaseEntity<SelfOpenAccountDetailEntity>> response) {
                DialogHelper.dismissProgressDialog();
                if (response.body() == null) {
                    return;
                }
                if (response.isSuccessful() && "ok".equals(response.body().getState())) {
                    if (response.body().getData().status == 1) {
                        if (tag == 1) {
                            ContractListActivity.start(context);
                        } else if (tag == 2) {
                            if (isUser){
                                UserOpenAccountInfoActivity.start(context);
                            }else{
                                AccountDetailActivity.start(context);
                            }
                        } else if (tag == 3) {
                            ContractActivity.start(context);
                        }
                    } else {
                        com.sgb.kjwl.utils.DialogHelper.showDialog(context, "温馨提示", "开通在线合同签约账户，即可使用在线合同签约", "马上开通", new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {
                                if (isUser){
                                    UserOpenAccountActivity.start(context);
                                }else {
                                    OpenAccountActivity.start(context);
                                }
                            }
                        });
                    }
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<SelfOpenAccountDetailEntity>> call, Throwable t) {
                DialogHelper.dismissProgressDialog();
                MToast.showToast(context, t.getMessage());
            }
        });
    }


    /**
     * 经营帮会员中心菜单app个人未实名认证获取所有个人菜单
     */

    public void getNoAuthPermissionMenu(String no) {
        MyLog.e("获取一级菜单", "开始=" + simpleDateFormat.format(new Date(System.currentTimeMillis())));
        APIManager.getInstance().getUserAPI().getUnAuthAllMenuPerson(no, "0").enqueue(new ICallBack<BaseEntity<List<PermissionMenuEntity>>>(true, true) {
            @RequiresApi(api = Build.VERSION_CODES.M)
            @Override
            public void onSuccess(BaseEntity<List<PermissionMenuEntity>> data) {
                if (data != null && data.getData() != null) {
                    fragment.showPermissionMenu(data.getData());
                } else {
                    fragment.dismissRefresh();
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PermissionMenuEntity>>> call, Throwable t) {
                //去登录
                if (fragment != null && fragment.getActivity() != null && !fragment.getActivity().isFinishing()) {
                    VerificationCodeLoginActivity.start(fragment.getActivity(), false);
                }

                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_TOKEN, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PC_TOKEN, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.LOGIN_PHONE, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourcePCToken, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.resourceAPPToken, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.ENTERPRISE_AUTH, "");
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.PERSON_AUTH, false);
                SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.DRIVER_AUTH, "");
                repertory.saveToken(null);
                fragment.dismissRefresh();
                fragment.getData();
            }
        });

    }
}

